﻿#Region "Imports"
Imports System.IO
Imports System.Net
Imports KeyboardHook
Imports System.Threading
Imports System.Drawing.Imaging
Imports System.Runtime.InteropServices
#End Region

Public Class FrmYouTube
#Region "Declerations"
    Dim YouTubeCreateAccountUrl As String = "https://accounts.google.com/SignUpWithoutGmail?service=youtube&continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26app%3Ddesktop%26feature%3Dsign_in_button%26hl%3Den%26next%3D%252F&hl=en"
    Public Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
    Public Declare Auto Function SetCursorPos Lib "User32.dll" (ByVal X As Integer, ByVal Y As Integer) As Long
    Public Declare Auto Function GetCursorPos Lib "User32.dll" (ByRef lpPoint As Point) As Long
    Dim AccountCountPath As String = Application.StartupPath & "\accountscount.txt"
    Dim DescriptionsPath As String = Application.StartupPath & "\descriptions\"
    Dim U2bviewsPath As String = Application.StartupPath & "\u2bviews.txt"
    Dim FirstNames As String = Application.StartupPath & "\firstnames.txt"
    Dim LastNames As String = Application.StartupPath & "\lastnames.txt"
    Dim VideosPath As String = Application.StartupPath & "\videos\"
    Private Shared ReadOnly HWND_NOTOPMOST As New IntPtr(-2)
    Private WithEvents KeyHook As New KeyboardLowLevelHook
    Private Shared ReadOnly HWND_TOPMOST As New IntPtr(-1)
    Dim AccountsPath As String = Application.StartupPath
    Dim CurrentU2bviewsPassword As String = String.Empty
    Dim CurrentU2bviewsAccount As String = String.Empty
    Dim CurrentAfterLastName As String = String.Empty
    Dim URLPath As String = Application.StartupPath
    Dim CurrentDescription As String = String.Empty
    Dim LastLocation As Point = New Point(100, 100)
    Dim GeneratedPassword As String = String.Empty
    Dim TotalTimeProcess As String = String.Empty
    Dim CurrentFirstName As String = String.Empty
    Dim CurrentLastName As String = String.Empty
    Dim CurrentPassword As String = String.Empty
    Dim LocationFound As Point = New Point(0, 0)
    Private VideoPath As String = String.Empty
    Public Const MOUSEEVENTF_MIDDLEDOWN = &H20
    Dim CurrentEmail As String = String.Empty
    Private Const SWP_NOSIZE As Integer = &H1
    Private Const SWP_NOMOVE As Integer = &H2
    Public Const MOUSEEVENTF_MIDDLEUP = &H40
    Public Const MOUSEEVENTF_RIGHTDOWN = &H8
    Dim ImagesPath As String = String.Empty
    Dim VideoToAdd As String = String.Empty
    Dim CurrentURL As String = String.Empty
    Public Const MOUSEEVENTF_LEFTDOWN = &H2
    Public Const MOUSEEVENTF_RIGHTUP = &H10
    Dim CurrentRandomNumber As Integer = 0
    Public Const MOUSEEVENTF_LEFTUP = &H4
    Dim ErrorLog As String = String.Empty
    Dim DoneWithCapcha As Boolean = False
    Dim TimeForCapcha As Boolean = False
    Dim AlarmStarted As Boolean = False
    Dim TempSearchErrors As Integer = 0
    Dim CurrentAccount As Integer = 0
    Dim DontCheck As Boolean = False
    Dim SearchErrors As Integer = 0
    Dim CurrentVideo As Integer = 0
    Dim CurrentTask As Integer = 0
    Dim CurrentTick As Integer = 0
    Dim TotalTime As Integer = 0
    Dim UpSeconds As Integer = 0
    Private Delegate Sub null()
    Dim RandomKey As RandomKey
#End Region

    <DllImport("user32.dll", SetLastError:=True)> Private Shared Function SetWindowPos _
    (ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal X As Integer, ByVal Y As Integer, _
     ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As Integer) As Boolean
    End Function

    Protected Overrides ReadOnly Property CreateParams() As CreateParams
        Get
            Const WS_EX_TOPMOST As Integer = &H8
            Dim cp As CreateParams = MyBase.CreateParams
            cp.ExStyle = cp.ExStyle Or WS_EX_TOPMOST
            Return cp
        End Get
    End Property

    Public Function MakeTopMost()
        SetWindowPos(Me.Handle(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
        Return Nothing
    End Function

    Public Function MakeNormal()
        SetWindowPos(Me.Handle(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
        Return Nothing
    End Function

    Private Sub KeyHook_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles KeyHook.KeyDown
        If e.KeyCode.ToString = "F10" Then
            BtnStart.PerformClick()
        End If
        If e.KeyCode.ToString = "F12" Then
            CurrentVideo = 1
            CurrentAccount = 1
            SendKeys.Send(GetSettingItem(VideosPath & "account" & CurrentAccount & ".txt", CurrentAccount & CurrentVideo))
        End If
        If TimeForCapcha = True And e.KeyCode.ToString.ToLower = "f9" Then
            e.Handled = True
            DoneWithCapcha = True
            TimeForCapcha = False
        End If
    End Sub

    Private Function ImageSearch(ByVal BMP As String) As Point
        If Not BMP.Length > 0 Then
            If Mid(BMP, BMP.Length - 6).Contains(".bmp") = True Then
                BMP = Mid(BMP, 1, BMP.Length - 4)
            End If
            If Mid(BMP, BMP.Length - 6).Contains(".jpg") = True Then
                BMP = Mid(BMP, 1, BMP.Length - 4)
            End If
            If Mid(BMP, BMP.Length - 6).Contains(".png") = True Then
                BMP = Mid(BMP, 1, BMP.Length - 4)
            End If
        End If
        Dim MonitorWidth As Integer = Screen.PrimaryScreen.Bounds.Width
        Dim MonitorHeight As Integer = Screen.PrimaryScreen.Bounds.Height
        Dim ScreenSize As Size = New Size(MonitorWidth, MonitorHeight)
        Dim IMG As New System.Drawing.Bitmap(MonitorWidth, MonitorHeight)
        Dim Cap As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(IMG)
        Cap.CopyFromScreen(New Point(0, 0), New Point(0, 0), ScreenSize)
        Return ImageLocation(IMG, Image.FromFile(ImagesPath & "\" & BMP & ".bmp"))
    End Function

    Public Function GetSettingItem(ByVal File As String, ByVal Identifier As String) As String
        Dim S As New IO.StreamReader(File) : Dim Result As String = ""
        Do While (S.Peek <> -1)
            Dim Line As String = S.ReadLine
            If Line.ToLower.StartsWith(Identifier.ToLower & ":") Then
                Result = Line.Substring(Identifier.Length + 2)
            End If
        Loop
        S.Dispose()
        Return Result
    End Function

    Public Function GetRandom(ByVal Min As Integer, ByVal Max As Integer) As Integer
        Static Generator As System.Random = New System.Random()
        Return Generator.Next(Min, Max)
    End Function

    Public Shared Function ImageLocation(src As Bitmap, ByRef bmp As Bitmap) As Point
        If src Is Nothing OrElse bmp Is Nothing Then Return Nothing
        If src.Width = bmp.Width AndAlso src.Height = bmp.Height Then
            If src.GetPixel(0, 0) = bmp.GetPixel(0, 0) Then
                Return New Point(0, 0)
            Else
                Return Nothing
            End If
        ElseIf src.Width < bmp.Width OrElse src.Height < bmp.Height Then
            Return Nothing
        End If
        Dim sr As New Rectangle(0, 0, src.Width, src.Height)
        Dim br As New Rectangle(0, 0, bmp.Width, bmp.Height)
        Dim srcLock As BitmapData = src.LockBits(sr, Imaging.ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb)
        Dim bmpLock As BitmapData = bmp.LockBits(br, Imaging.ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb)
        Dim sStride As Integer = srcLock.Stride
        Dim bStride As Integer = bmpLock.Stride
        Dim srcSz As Integer = sStride * src.Height
        Dim bmpSz As Integer = bStride * bmp.Height
        Dim srcBuff(srcSz) As Byte
        Dim bmpBuff(bmpSz) As Byte
        Marshal.Copy(srcLock.Scan0, srcBuff, 0, srcSz)
        Marshal.Copy(bmpLock.Scan0, bmpBuff, 0, bmpSz)
        bmp.UnlockBits(bmpLock)
        src.UnlockBits(srcLock)
        Dim x, y, x2, y2, sx, sy, bx, by, sw, sh, bw, bh As Integer
        Dim r, g, b As Byte
        Dim p As Point = Nothing
        bw = bmp.Width
        bh = bmp.Height
        sw = src.Width - bw
        sh = src.Height - bh
        bx = 0 : by = 0
        For y = 0 To sh
            sy = y * sStride
            For x = 0 To sw
                sx = sy + x * 3
                r = srcBuff(sx + 2)
                g = srcBuff(sx + 1)
                b = srcBuff(sx)
                If r = bmpBuff(2) AndAlso g = bmpBuff(1) AndAlso b = bmpBuff(0) Then
                    p = New Point(x, y)
                    For y2 = 0 To bh - 1
                        by = y2 * bStride
                        For x2 = 0 To bw - 1
                            bx = by + x2 * 3
                            sy = (y + y2) * sStride
                            sx = sy + (x + x2) * 3
                            r = srcBuff(sx + 2)
                            g = srcBuff(sx + 1)
                            b = srcBuff(sx)
                            If Not (r = bmpBuff(bx + 2) AndAlso
                                    g = bmpBuff(bx + 1) AndAlso
                                    b = bmpBuff(bx)) Then
                                p = Nothing
                                sy = y * sStride
                                Exit For
                            End If
                        Next
                        If p = Nothing Then Exit For
                    Next
                End If
                If p <> Nothing Then Exit For
            Next
            If p <> Nothing Then Exit For
        Next
        bmpBuff = Nothing
        srcBuff = Nothing
        Return p
    End Function

    Private Function UpdateError(ByVal StrError As String) As Boolean
        FrmError.Show()
        FrmError.ListErrors.Text &= StrError & vbNewLine
        Return True
    End Function

    Private Function ChangeMD5(ByVal strFile As String) As Boolean
        Try
            Using fs As New FileStream(strFile, FileMode.Open, FileAccess.ReadWrite)
                fs.Position = fs.Length
                Dim tmp() As Byte = Nothing
                Array.Resize(tmp, 1)
                fs.Write(tmp, 0, 1)
                fs.Flush()
                fs.Close()
            End Using
            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

    Private Function ChangeFileMD5() As Boolean
        Try
            Dim mThread As New Thread(AddressOf ChangeHashes)
            mThread.Name = "md5Changer"
            mThread.Priority = ThreadPriority.Normal
            mThread.Start()
            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

    Private Sub ChangeHashes()
        If InvokeRequired Then
            Dim del As New null(AddressOf ChangeHashes)
            BeginInvoke(del)
        Else
            Dim tmpFile As String = String.Empty
            tmpFile = VideoPath
            If ChangeMD5(tmpFile) = False Then
                UpdateError("Couldn't change files '" & tmpFile & "' md5")
            End If
        End If
    End Sub

    Private Function ChangeStatus(Status As String)
        LabelStatus.Text = "Status: " & Status
        Return Nothing
    End Function

    Private Function ShowError(StringError As String)
        FrmError.Show()
        TimerTasks.Stop()
        TimerTotalTime.Stop()
        TotalTime = 0
        ChangeStatus(StringError)
        FrmError.ListErrors.Text &= StringError & vbNewLine
        Return Nothing
    End Function

    Private Function ClickMouse(ByVal MouseEvent As String)
        If MouseEvent.ToLower = "left" Then
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
        ElseIf MouseEvent.ToLower = "right" Then
            mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
        ElseIf MouseEvent.ToLower = "middle" Then
            mouse_event(MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0)
            mouse_event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0)
        End If
        Return Nothing
    End Function

    Private Function IsProcessRunning(name As String) As Boolean
        For Each CCleanerPro As Process In Process.GetProcesses()
            If CCleanerPro.ProcessName.StartsWith(name) Then
                Return True
            End If
        Next
        Return False
    End Function

    Private Sub FrmYouTube_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
        Application.Exit()
    End Sub

    Private Sub FrmYouTube_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        MakeNormal()
        RandomKey = New RandomKey
        RandomKey.KeyLetters = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz"
        RandomKey.KeyNumbers = "0123456789"
        RandomKey.KeyChars = 15
        CurrentAccount = My.Settings.CurrentAccount
        If My.Settings.Profile1Path = String.Empty Then
            MsgBox("Profile 1 images path is missing", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Title:="Error")
        End If
        If My.Settings.Profile2Path = String.Empty Then
            MsgBox("Profile 2 images path is missing", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Title:="Error")
        End If
        If My.Settings.FirefoxPath = String.Empty Then
            MsgBox("Firefox path is missing", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Title:="Error")
        End If
        If My.Settings.CCleanerPath = String.Empty Then
            MsgBox("CCleaner path is missing", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Title:="Error")
        End If
        If My.Settings.ProfileSelected = 1 Then
            ImagesPath = My.Settings.Profile1Path
        End If
        If My.Settings.ProfileSelected = 2 Then
            ImagesPath = My.Settings.Profile2Path
        End If
    End Sub

    Private Sub BtnMinimize_Click(sender As Object, e As EventArgs) Handles BtnMinimize.Click
        Me.WindowState = FormWindowState.Minimized
    End Sub

    Private Sub BtnClose_Click(sender As Object, e As EventArgs) Handles BtnClose.Click
        Application.Exit()
    End Sub

    Private Sub BtnStart_Click(sender As Object, e As EventArgs) Handles BtnStart.Click
        Dim AccountPaths As String = Application.StartupPath & "\accounts.txt"
        If BtnStart.Text = "Start" Then
            BtnStart.Text = "Stop"
            FileOpen(99, AccountPaths, OpenMode.Output)
            PrintLine(99, String.Empty)
            FileClose(99)
            LastLocation = Me.Location
            Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
            Me.Location = New Point((Screen.PrimaryScreen.Bounds.Width - Me.Width), (Screen.PrimaryScreen.Bounds.Height - Me.Height))
            LabelStatus.ForeColor = Color.Black
            ChangeStatus("Opening CCleaner")
            ProgressBarProgress.Value += 4
            TimerTasks.Start()
            CurrentTask = 1
            CurrentTick = 0
            MakeTopMost()
        Else
            MakeNormal()
            TotalTime = 0
            CurrentTask = 0
            CurrentTick = 0
            TimerTasks.Stop()
            TimerTotalTime.Stop()
            BtnStart.Text = "Start"
            Me.Location = LastLocation
            ProgressBarProgress.Value = 0
            ChangeStatus("Waiting start command")
            Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle
        End If
    End Sub

    Private Sub TimerTasks_Tick(sender As Object, e As EventArgs) Handles TimerTasks.Tick
        LabelNumbers.Text = CurrentTask & " - " & CurrentTick
        LabelProgress.Text = ProgressBarProgress.Value & "%"
        'The Start //
        If CurrentTask = 1 Then
            'Open ccleaner /
            CurrentTick += 1
            If CurrentTick = 1 Then
                Process.Start(My.Settings.CCleanerPath, "/AUTO")
            ElseIf CurrentTick = 50 Then
                ChangeStatus("Checking if CCleaner is finished")
                CurrentTask = 2
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 2 Then
            'Check if ccleaner is open
            If IsProcessRunning("CCleaner") = False Then
                CurrentTick += 1
            End If
            If CurrentTick = 2 Then
                ChangeStatus("Opening Firefox")
                CurrentTask = 3
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 3 Then
            'Create hotmail account /
            'Open firefox
            CurrentTick += 1
            If CurrentTick = 10 Then
                Process.Start(My.Settings.FirefoxPath, "http://www.hotmail.com")
            ElseIf CurrentTick > 10 Then
                ChangeStatus("Waiting for Firefox to open")
                CurrentTask = 4
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 4 Then
            'Check if firefox is open
            If IsProcessRunning("firefox") = True Then
                CurrentTick += 1
            End If
            If CurrentTick = 100 Then
                ChangeStatus("Searching for sign up button (" & SearchErrors & " of 25)")
                SetCursorPos(LocationFound.X, LocationFound.Y)
                CurrentTask = 5
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 5 Then
            'Check for create account link
            ChangeStatus("Searching for sign up button (" & SearchErrors & " of 25)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("hotmail01")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 6
                    SearchErrors = 0
                    ChangeStatus("Clicking sign up button")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 25 Then
                ShowError("Couldn't find the image 'hotmail01'")
            End If
        ElseIf CurrentTask = 6 Then
            'Clicking create account link
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Searching for first name textbox (" & SearchErrors & " of 25)")
                CurrentTask = 7
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 7 Then
            'Searching for first name
            ChangeStatus("Searching for sign up button (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("hotmail02")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 8
                    SearchErrors = 0
                    ChangeStatus("Clicking first name textbox")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 25 Then
                ShowError("Couldn't find the image 'hotmail02'")
            End If
        ElseIf CurrentTask = 8 Then
            'Clicking first name
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Entering informations")
                CurrentTask = 9
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 9 Then
            'Entering info
            CurrentTick += 1
            If CurrentTick = 5 Then
                CurrentFirstName = GetSettingItem(FirstNames, GetRandom(1, 288))
                CurrentLastName = GetSettingItem(LastNames, GetRandom(1, 288))
                CurrentRandomNumber = GetRandom(1, 3)
                If CurrentRandomNumber = 1 Then CurrentLastName &= "el"
                If CurrentRandomNumber = 2 Then CurrentLastName &= "t"
                If CurrentRandomNumber = 3 Then CurrentLastName &= "in"
                CurrentEmail = CurrentFirstName & CurrentLastName & GetRandom(100, 999)
                GeneratedPassword = RandomKey.Generate
                If Mid(GeneratedPassword, 1, 2) = "E:" Then
                    MsgBox("Couldn't generate password", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Title:="Error")
                    ChangeStatus("ERROR: CAN'T GENERATE PASSWORD")
                    LabelStatus.ForeColor = Color.Red
                    TimerTasks.Stop()
                    TimerTotalTime.Stop()
                    TotalTime = 0
                End If
                CurrentPassword = GeneratedPassword
                My.Settings.FullName = CurrentFirstName & " " & CurrentLastName
                My.Settings.Email = CurrentEmail.ToLower & "@outlook.com"
                My.Settings.Password = CurrentPassword
                ErrorLog = SavingClass.SaveAccount(AccountsPath)
                If Not ErrorLog = "OK" Then
                    If MsgBox("Couldn't save account, Error: " & ErrorLog & "Do you want to continue?", MsgBoxStyle.Critical + MsgBoxStyle.YesNo, Title:="Error") = MsgBoxResult.No Then
                        ChangeStatus("ERROR: CAN'T SAVE ACCOUNT")
                        LabelStatus.ForeColor = Color.Red
                        TimerTasks.Stop()
                        TimerTotalTime.Stop()
                        TotalTime = 0
                    End If
                End If
                SendKeys.Send(CurrentFirstName)
                SendKeys.Send("{TAB}")
                SendKeys.Send(CurrentLastName)
                SendKeys.Send("{TAB}")
                SendKeys.Send(CurrentEmail.ToLower)
                SendKeys.Send("{TAB 2}")
                SendKeys.Send(CurrentPassword)
                SendKeys.Send("{TAB}")
                SendKeys.Send(CurrentPassword)
                SendKeys.Send("{TAB 2}")
                SendKeys.Send("10001")
                SendKeys.Send("{TAB}")
                SendKeys.Send("{DOWN 3}")
                SendKeys.Send("{TAB}")
                SendKeys.Send("{DOWN 2}")
                SendKeys.Send("{TAB}")
                SendKeys.Send("{DOWN 22}")
                SendKeys.Send("{TAB}")
                SendKeys.Send("{DOWN}")
                SendKeys.Send("{TAB 2}")
                SendKeys.Send("212555" & GetRandom(1, 9) & GetRandom(1, 9) & GetRandom(1, 9) & GetRandom(1, 9))
                SendKeys.Send("{TAB 4}")
                ChangeStatus("Waiting for capcha, press F9 when done")
                DoneWithCapcha = False
                TimeForCapcha = True
                CurrentTask = 10
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 10 Then
            'Waiting for capcha
            If DoneWithCapcha = True Then
                CurrentTask = 11
                ChangeStatus("Finishing account")
            End If
        ElseIf CurrentTask = 11 Then
            'Finishing account
            CurrentTick += 1
            If CurrentTick = 5 Then
                SendKeys.Send("{TAB 4}")
                SendKeys.Send("{ENTER}")
                ChangeStatus("Searching for capcha error (" & SearchErrors & " of 15)")
            ElseIf CurrentTick > 5 Then
                CurrentTask = 102
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 12 Then
            'Searching for the continue to inbox button
            ChangeStatus("Searching for continue button (" & SearchErrors & " of 25)")
            CurrentTick += 1
            If CurrentTick = 55 Then
                LocationFound = ImageSearch("hotmail04")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 13
                    ChangeStatus("Clicking continue button")
                End If
            ElseIf CurrentTick > 55 Then
                CurrentTick = 50
            End If
            If SearchErrors >= 35 Then
                ShowError("Couldn't find the image 'hotmail04'")
            End If
        ElseIf CurrentTask = 13 Then
            'Clicking continue to inbox button
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Closing Firefox")
                CurrentTask = 14
                CurrentTick = 0
            End If
            'Done creating hotmail account ///
        ElseIf CurrentTask = 14 Then
            'Creating youtube account //
            'Opening create youtube account /
            CurrentTick += 1
            If CurrentTick = 5 Then
                Process.Start(My.Settings.FirefoxPath, YouTubeCreateAccountUrl)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Waiting for Firefox to open")
                CurrentTask = 15
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 15 Then
            'Checking if Firefox process exists
            If IsProcessRunning("firefox") = True Then
                CurrentTick += 1
            End If
            If CurrentTick = 100 Then
                ChangeStatus("Searching for first name textbox (" & SearchErrors & " of 25)")
                CurrentTask = 16
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 16 Then
            'Search for first name textbox
            ChangeStatus("Searching for first name textbox (" & SearchErrors & " of 25)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("youtube03")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 17
                    ChangeStatus("Clicking first name textbox")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 25 Then
                ShowError("Couldn't find the image 'youtube03'")
            End If
        ElseIf CurrentTask = 17 Then
            'Clicking first name textbox
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Entering info")
                CurrentTask = 18
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 18 Then
            'Entering info
            CurrentTick += 1
            If CurrentTick = 5 Then
                SendKeys.Send(CurrentFirstName)
                SendKeys.Send("{TAB}")
                SendKeys.Send(CurrentLastName)
                SendKeys.Send("{TAB}")
                SendKeys.Send(CurrentEmail.ToLower & "@outlook.com")
                SendKeys.Send("{TAB}{TAB}")
                SendKeys.Send(CurrentPassword)
                SendKeys.Send("{TAB}")
                SendKeys.Send(CurrentPassword)
                SendKeys.Send("{TAB}")
                SendKeys.Send("{DOWN " & GetRandom(2, 13) & "}")
                SendKeys.Send("{ENTER}")
                SendKeys.Send("{TAB}")
                SendKeys.Send(GetRandom(1, 27))
                SendKeys.Send("{TAB}")
                SendKeys.Send(GetRandom(1993, 1995))
                SendKeys.Send("{TAB}")
                SendKeys.Send("{DOWN}{DOWN}{DOWN}{ENTER}")
                SendKeys.Send("{TAB}{TAB}{TAB}{TAB}")
                ChangeStatus("Waiting for capcha, press F9 to continue")
                TimeForCapcha = True
                DoneWithCapcha = False
                CurrentTask = 19
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 19 Then
            'Waiting for capcha
            If DoneWithCapcha = True Then
                CurrentTick += 1
            End If
            If CurrentTick = 2 Then
                ChangeStatus("Finishing account")
                CurrentTask = 20
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 20 Then
            'Finishing account
            CurrentTick += 1
            If CurrentTick = 5 Then
                SendKeys.Send("{TAB}{TAB}{TAB}{TAB}{TAB}")
                If DontCheck = False Then
                    SendKeys.Send(" ")
                Else
                    DontCheck = False
                End If
                SendKeys.Send("{TAB}{TAB}{TAB}")
                SendKeys.Send("{ENTER}")
                ChangeStatus("Searching verify account (" & SearchErrors & " of 35)")
                CurrentTask = 21
                CurrentTick = 24
                SearchErrors = 0
            End If
        ElseIf CurrentTask = 21 Then
            'Checking to verify account *****************************************
            ChangeStatus("Searching verify account (" & SearchErrors & " of 35)")
            CurrentTick += 1
            If CurrentTick = 25 Then
                LocationFound = ImageSearch("ytverifyemail")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 113
                    SearchErrors = 0
                    ChangeStatus("Searching verify account (" & SearchErrors & " of 15)")
                End If
            ElseIf CurrentTick > 25 Then
                CurrentTick = 20
            End If
            If SearchErrors >= 35 Then
                ShowError("Couldn't find the image 'ytverifyemail'")
            End If
        ElseIf CurrentTask = 22 Then
            'Waiting for youtube to finish loading
            CurrentTick += 1
            If CurrentTick = 50 Then
                ChangeStatus("Searching for close tab button (" & SearchErrors & " of 15)")
                CurrentTask = 23
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 23 Then
            'Closing youtube tab
            ChangeStatus("Searching for close tab button (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("ytclosetab")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 24
                    SearchErrors = 0
                    ChangeStatus("Clicking close tab button")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors >= 15 Then
                ShowError("Couldn't find the image 'ytclosetab'")
            End If
        ElseIf CurrentTask = 24 Then
            'Clicking close youtube tab
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
                SearchErrors = 0
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Searching for refreh button (" & SearchErrors & " of 15)")
                CurrentTask = 25
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 25 Then
            'Searching for refresh button {loop with 26}
            ChangeStatus("Searching for refreh button (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("hotmailrefresh")
                If LocationFound = New Point(0, 0) Then
                    TempSearchErrors += 1
                    CurrentTick = 0
                Else
                    SetCursorPos(LocationFound.X + 5, LocationFound.Y + 5)
                    ClickMouse("left")
                    LocationFound = New Point(0, 0)
                    CurrentTick = 0
                    CurrentTask = 26
                    TempSearchErrors = 0
                    ChangeStatus("Searching for activation link (" & SearchErrors & " of 35)")
                End If
            End If
            If TempSearchErrors = 15 Then
                ShowError("Couldn't find the image 'hotmailrefresh'")
            End If
        ElseIf CurrentTask = 26 Then
            'Searching for activation link {loop with 25}
            ChangeStatus("Searching for activation link (" & SearchErrors & " of 35)")
            CurrentTick += 1
            If CurrentTick = 15 Then
                LocationFound = ImageSearch("ytverify")
                If LocationFound = New Point(0, 0) Then
                    CurrentTick = 0
                    CurrentTask = 25
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 27
                    ChangeStatus("Clicking activation link")
                End If
            ElseIf CurrentTick > 15 Then
                CurrentTick = 0
            End If
            If SearchErrors = 35 Then
                ShowError("Couldn't find the image 'ytverify'")
            End If
        ElseIf CurrentTask = 27 Then
            'Clicking activation link
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Searching for next step button (" & SearchErrors & " of 15)")
                CurrentTask = 28
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 28 Then
            'Searching for verification link
            ChangeStatus("Searching for activation link (" & SearchErrors & " of 35)")
            CurrentTick += 1
            If CurrentTick = 15 Then
                LocationFound = ImageSearch("ytverifylink")
                If LocationFound = New Point(0, 0) Then
                    CurrentTick = 0
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 29
                    SearchErrors = 0
                    ChangeStatus("Clicking activation link")
                End If
            ElseIf CurrentTick > 15 Then
                CurrentTick = 0
            End If
            If SearchErrors >= 35 Then
                ShowError("Couldn't find the image 'ytverifylink'")
            End If
        ElseIf CurrentTask = 29 Then
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y + 2)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Searching for next step button (" & SearchErrors & " of 15)")
                CurrentTask = 30
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 30 Then
            'Searching for next step button
            ChangeStatus("Searching for next step button (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("ytnextstep")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 31
                    ChangeStatus("Clicking next step button")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'ytnextstep'")
            End If
        ElseIf CurrentTask = 31 Then
            'Click next step button
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Searching for back to youtube button (" & SearchErrors & " of 15)")
                CurrentTask = 32
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 32 Then
            'Searching for back to youtube button
            ChangeStatus("Searching for back to youtube button (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("ytback")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 33
                    ChangeStatus("Clicking next step button")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'ytback'")
            End If
        ElseIf CurrentTask = 33 Then
            'Click back to youtube button
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Searching for next > button (" & SearchErrors & " of 35)")
                CurrentTask = 34
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 34 Then
            'Check for next > button
            ChangeStatus("Searching for next > button (" & SearchErrors & " of 35)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("ytnext")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 35
                    ChangeStatus("Clicking next step button")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 35 Then
                ShowError("Couldn't find the image 'ytnext'")
            End If
        ElseIf CurrentTask = 35 Then
            'Click next > button
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Searching for save > button (" & SearchErrors & " of 15)")
                CurrentTask = 36
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 36 Then
            'Searching for save > button
            ChangeStatus("Searching for save > button (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("ytnext2")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                    SetCursorPos(200, 200)
                Else
                    CurrentTick = 0
                    CurrentTask = 37
                    ChangeStatus("Clicking save button")
                    SetCursorPos(LocationFound.X, LocationFound.Y)
                    ClickMouse("left")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'ytnext2'")
            End If
        ElseIf CurrentTask = 37 Then
            'Searching for close tab button
            ChangeStatus("Searching for close tab button (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("hotmailclosetab")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 38
                    ChangeStatus("Clicking close tab button")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'hotmailclosetab'")
            End If
        ElseIf CurrentTask = 38 Then
            'Click close tab button
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Opening youtube defaults")
                CurrentTask = 39
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 39 Then
            'Opening youtube defaults tab
            CurrentTick += 1
            If CurrentTick = 5 Then
                Process.Start(My.Settings.FirefoxPath, "https://www.youtube.com/upload_defaults")
            ElseIf CurrentTick > 60 Then
                ChangeStatus("Searching for public dropbox (" & SearchErrors & " of 15)")
                CurrentTask = 40
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 40 Then
            'Searching for public dropbox
            ChangeStatus("Searching for public dropbox (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("ytsettingspublic")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 41
                    ChangeStatus("Clicking public dropbox")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'ytsettingspublic'")
            End If
        ElseIf CurrentTask = 41 Then
            'Clicking public dropbox
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Entering info")
                CurrentTask = 42
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 42 Then
            'Entering info
            CurrentTick += 1
            If CurrentTick = 5 Then
                SendKeys.Send("{DOWN}{ENTER}")
                SendKeys.Send("{TAB}{TAB}{TAB}{TAB}")
                SendKeys.Send(File.ReadAllText(DescriptionsPath & "account" & CurrentAccount & ".txt"))
                SendKeys.Send("{TAB}{TAB}{TAB}")
                SendKeys.Send("{ENTER}{DOWN}{ENTER}")
                SendKeys.Send("{TAB}{TAB}")
                SendKeys.Send(" ")
                ChangeStatus("Searching for save button (" & SearchErrors & " of 15)")
                CurrentTask = 43
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 43 Then
            'Search for save button
            ChangeStatus("Searching for save button (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("ytsettingssave")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 44
                    SearchErrors = 0
                    ChangeStatus("Clicking save button")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'ytsettingssave'")
            End If
        ElseIf CurrentTask = 44 Then
            'Clicking save button
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 60 Then
                ChangeStatus("Searching for upload button (" & SearchErrors & " of 15)")
                CurrentTask = 45
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 45 Then
            'Searching for upload
            ChangeStatus("Searching for upload button (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("upload01")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 46
                    SearchErrors = 0
                    ChangeStatus("Clicking upload button")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'upload01'")
            End If
        ElseIf CurrentTask = 46 Then
            'Clicking upload button
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 60 Then
                ChangeStatus("Searching for OK button (" & SearchErrors & " of 15)")
                CurrentTask = 47
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 47 Then
            'Searching for OK button
            ChangeStatus("Searching for OK button (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("ytfirstok")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 48
                    SearchErrors = 0
                    ChangeStatus("Clicking OK button")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'ytfirstok'")
            End If
        ElseIf CurrentTask = 48 Then
            'Clicking OK button
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Searching for upload button (" & SearchErrors & " of 15)")
                CurrentTask = 49
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 49 Then
            'Checking for stuff {loop with 66 or 67} ******************************************
            CurrentTick += 1
            If CurrentTick = 5 Then
                If Not GetSettingItem(VideosPath & "account" & CurrentAccount & ".txt", CurrentAccount & CurrentVideo) = String.Empty Then
                    ChangeMD5(GetSettingItem(VideosPath & "account" & CurrentAccount & ".txt", CurrentAccount & CurrentVideo))
                End If
            ElseIf CurrentTick > 25 Then
                CurrentVideo += 1
                If GetSettingItem(VideosPath & "account" & CurrentAccount & ".txt", CurrentAccount & CurrentVideo) = String.Empty Then
                    ChangeStatus("No more videos going to the next account")
                    CurrentTask = 67
                    CurrentTick = 0
                Else
                    If CurrentVideo = 1 Then
                        ChangeStatus("Video found going to the video")
                    Else
                        ChangeStatus("Video found going to the next video")
                    End If
                    CurrentTask = 50
                    CurrentTick = 0
                End If
            End If
        ElseIf CurrentTask = 50 Then
            'Searching start upload button
            ChangeStatus("Searching for start upload button (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("upload02")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 51
                    SearchErrors = 0
                    ChangeStatus("Clicking start upload button")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'upload02'")
            End If
        ElseIf CurrentTask = 51 Then
            'Clicking start upload button
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Entering path")
                CurrentTask = 52
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 52 Then
            'Entering path
            CurrentTick += 1
            If CurrentTick = 20 Then
                SendKeys.Send(GetSettingItem(VideosPath & "account" & CurrentAccount & ".txt", CurrentAccount & CurrentVideo))
                Thread.Sleep(2000)
                SendKeys.Send("{ENTER}")
                ChangeStatus("Waiting for video to finish upload (" & SearchErrors & " of 300)")
                SearchErrors = 0
                CurrentTask = 53
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 53 Then
            'Waiting for video to finish upload
            ChangeStatus("Waiting for video to finish upload (" & SearchErrors & " of 300)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("ytprocdone")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 54
                    SearchErrors = 0
                    ChangeStatus("Searching for done button (" & SearchErrors & " of 15)")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 300 Then
                ShowError("Couldn't find the image 'ytprocdone'")
            End If
        ElseIf CurrentTask = 54 Then
            'Searching for done button
            ChangeStatus("Searching for done button (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("ytuploaddone")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 55
                    SearchErrors = 0
                    ChangeStatus("Clicking done button")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'ytuploaddone'")
            End If
        ElseIf CurrentTask = 55 Then
            'Clicking done button
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 60 Then
                ChangeStatus("Searching for video link (" & SearchErrors & " of 15)")
                CurrentTask = 56
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 56 Then
            'Searching for video link
            ChangeStatus("Searching for video link (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("ytlink")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    SearchErrors = 0
                    CurrentTask = 57
                    ChangeStatus("Clicking youtube link")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'ytlink'")
            End If
        ElseIf CurrentTask = 57 Then
            'Clicking video link
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Searching for browser link (" & SearchErrors & " of 15)")
                CurrentTask = 58
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 58 Then
            'Searching for browser link
            ChangeStatus("Searching for browser link (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("ytlink2")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    SearchErrors = 0
                    CurrentTask = 59
                    ChangeStatus("Clicking browser link")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'ytlink2'")
            End If
        ElseIf CurrentTask = 59 Then
            'Clicking browser link
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X + 100, LocationFound.Y + 5)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Copying link")
                CurrentTask = 60
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 60 Then
            'Copying browser link and process it
            CurrentTick += 1
            If CurrentTick = 5 Then
                SendKeys.Send("^(c)")
                CurrentTask = 61
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 61 Then
            'Saving video link
            CurrentTick += 1
            If CurrentTick = 5 Then
                CurrentURL = Replace(Clipboard.GetText(), "&feature=youtu.be", "")
                My.Settings.CurrentAccount = CurrentAccount
                My.Settings.CurrentVideo = CurrentVideo
                My.Settings.CurrentURL = CurrentURL
                ErrorLog = SavingClass.SaveURL(URLPath)
                If Not ErrorLog = "OK" Then
                    If MsgBox("Couldn't save URL, Error: " & ErrorLog & "Do you want to continue?", MsgBoxStyle.Critical + MsgBoxStyle.YesNo, Title:="Error") = MsgBoxResult.No Then
                        ChangeStatus("ERROR: CAN'T SAVE ACCOUNT")
                        LabelStatus.ForeColor = Color.Red
                        TimerTasks.Stop()
                        TimerTotalTime.Stop()
                        TotalTime = 0
                    End If
                End If
                CurrentTask = 62
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 62 Then
            'Searching to close upload tab
            ChangeStatus("Searching for close tab button (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("ytclosetab")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 63
                    SearchErrors = 0
                    ChangeStatus("Clicking close tab button")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'ytclosetab'")
            End If
        ElseIf CurrentTask = 63 Then
            'Clicking close youtube tab
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Searching for refreh button (" & SearchErrors & " of 15)")
                CurrentTask = 64
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 64 Then
            'Searching for upload button
            ChangeStatus("Searching for upload button (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("upload01")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 65
                    SearchErrors = 0
                    ChangeStatus("Clicking upload button")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'upload01'")
            End If
        ElseIf CurrentTask = 65 Then
            'Clicking upload button
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Going to loop")
                CurrentTask = 66
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 66 Then
            'Going to loop {loop with 49}
            CurrentTick += 1
            If CurrentTick = 5 Then
                CurrentTask = 49
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 67 Then
            'Going to the next account
            CurrentAccount += 1
            If File.ReadAllText(AccountCountPath) >= CurrentAccount Then
                CurrentTask = 68
                CurrentTick = 0
            Else
                CurrentTask = 70
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 68 Then
            CurrentTick += 1
            If CurrentTick = 10 Then
                SendKeys.Send("^+{DELETE}")
                CurrentTask = 69
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 69 Then
            CurrentTick += 1
            If CurrentTick = 50 Then
                SendKeys.Send("{ENTER}")
            ElseIf CurrentTick > 70 Then
                CurrentTick = 0
                CurrentTask = 107
            End If
        ElseIf CurrentTask = 70 Then
            'Opening firefox
            ChangeStatus("Opening Firefox")
            CurrentTick += 1
            If CurrentTick = 5 Then
                Process.Start(My.Settings.FirefoxPath, "http://u2bviews.com/login/")
            ElseIf CurrentTick > 50 Then
                ChangeStatus("Waiting for Firefox to open")
                CurrentTask = 71
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 71 Then
            'Searching for username textbox
            ChangeStatus("Searching for upload button (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("u2bviewsuser")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 72
                    SearchErrors = 0
                    ChangeStatus("Clicking username textbox")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'u2bviewsuser'")
            End If
        ElseIf CurrentTask = 72 Then
            'Clicking username textbox
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X + 70, LocationFound.Y + 2)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Entering info")
                CurrentTask = 73
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 73 Then
            'Entering info
            CurrentU2bviewsAccount = GetSettingItem(U2bviewsPath, "account")
            CurrentU2bviewsPassword = GetSettingItem(U2bviewsPath, "password")
            SendKeys.Send(CurrentU2bviewsAccount)
            SendKeys.Send("{TAB}")
            SendKeys.Send(CurrentU2bviewsPassword)
            SendKeys.Send("{ENTER}")
            ChangeStatus("Searching for control panel button (" & SearchErrors & " of 15)")
            CurrentTask = 74
            CurrentTick = 0
        ElseIf CurrentTask = 74 Then
            'Searching for control panel
            ChangeStatus("Searching for control panel button (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("u2bviews06")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 75
                    SearchErrors = 0
                    ChangeStatus("Clicking control panel button")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'u2bviews06'")
            End If
        ElseIf CurrentTask = 75 Then
            'Clicking control panel
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Searching for my videos button (" & SearchErrors & " of 15)")
                CurrentTask = 76
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 76 Then
            'Searching for my videos button
            ChangeStatus("Searching for control panel button (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("u2bviews07")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 77
                    SearchErrors = 0
                    ChangeStatus("Clicking my videos button")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'u2bviews07'")
            End If
        ElseIf CurrentTask = 77 Then
            'Clicking my videos button
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Searching for url textbox (" & SearchErrors & " of 15)")
                CurrentTask = 78
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 78 Then
            'Searching for url textbox
            ChangeStatus("Searching for url textbox (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("u2bviews08")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 79
                    SearchErrors = 0
                    ChangeStatus("Clicking url textbox")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'u2bviews08'")
            End If
        ElseIf CurrentTask = 79 Then
            'Clicking url textbox
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Entering info")
                CurrentTask = 80
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 80 Then
            'Entering info
            CurrentTick += 1
            If CurrentTick = 5 Then
                My.Settings.CurrentAccount = 1
                My.Settings.CurrentVideo = 1
                CurrentAccount = My.Settings.CurrentAccount
                CurrentVideo = My.Settings.CurrentVideo
                ErrorLog = SavingClass.LoadURL(URLPath)
                If Not ErrorLog = "OK" Then
                    If MsgBox("Couldn't find video URL, Error: " & ErrorLog & "Do you want to continue?", MsgBoxStyle.Critical + MsgBoxStyle.YesNo, Title:="Error") = MsgBoxResult.No Then
                        ChangeStatus("ERROR: CAN'T LOAD URL")
                        LabelStatus.ForeColor = Color.Red
                        TimerTasks.Stop()
                        TimerTotalTime.Stop()
                        TotalTime = 0
                    End If
                End If
                CurrentURL = My.Settings.CurrentURL
                CurrentTask = 113
                CurrentTick = 0
                SendKeys.Send(CurrentURL)
                SendKeys.Send("{TAB}")
                SendKeys.Send("250")
            ElseIf CurrentTick = 15 Then
                SendKeys.Send("{ENTER}")
            ElseIf CurrentTick = 25 Then
                ChangeStatus("Searching for continue button (" & SearchErrors & " of 15)")
                CurrentTask = 81
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 81 Then
            'Searching for continue button
            ChangeStatus("Searching for continue button (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("u2bviews14")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 82
                    SearchErrors = 0
                    ChangeStatus("Clicking url textbox")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'u2bviews14'")
            End If
        ElseIf CurrentTask = 82 Then
            'Clicking continue button
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Entering info")
                CurrentTask = 83
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 83 Then
            'Searching url textbox {loop with 85}
            ChangeStatus("Searching for url textbox (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("u2bviews08")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 84
                    SearchErrors = 0
                    ChangeStatus("Clicking url textbox")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'u2bviews08'")
            End If
        ElseIf CurrentTask = 84 Then
            'Clicking url textbox
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Entering info")
                CurrentTask = 85
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 85 Then
            'Entering url
            My.Settings.CurrentAccount = 1
            My.Settings.CurrentURL = 1
            ErrorLog = SavingClass.LoadURL(URLPath)
            If Not ErrorLog = "OK" Then
                If MsgBox("Couldn't find video URL, Error: " & ErrorLog & "Do you want to continue?", MsgBoxStyle.Critical + MsgBoxStyle.YesNo, Title:="Error") = MsgBoxResult.No Then
                    ChangeStatus("ERROR: CAN'T LOAD URL")
                    LabelStatus.ForeColor = Color.Red
                    TimerTasks.Stop()
                    TimerTotalTime.Stop()
                    TotalTime = 0
                End If
            End If
            CurrentURL = My.Settings.CurrentURL
            If CurrentURL = String.Empty Then
                CurrentVideo = 1
                CurrentAccount += 1
                If File.ReadAllText(AccountCountPath) < CurrentAccount Then
                    CurrentTask = 88
                    CurrentTick = 0
                    TimerTasks.Stop()
                    TimerTotalTime.Stop()
                    TotalTime = 0
                End If
                My.Settings.CurrentAccount = CurrentAccount
                My.Settings.CurrentURL = CurrentURL
                ErrorLog = SavingClass.LoadURL(URLPath)
                If Not ErrorLog = "OK" Then
                    If MsgBox("Couldn't find video URL, Error: " & ErrorLog & "Do you want to continue?", MsgBoxStyle.Critical + MsgBoxStyle.YesNo, Title:="Error") = MsgBoxResult.No Then
                        ChangeStatus("ERROR: CAN'T LOAD URL")
                        LabelStatus.ForeColor = Color.Red
                        TimerTasks.Stop()
                        TimerTotalTime.Stop()
                        TotalTime = 0
                    End If
                End If
            End If
            CurrentURL = My.Settings.CurrentURL
            If CurrentURL = String.Empty Then
                CurrentTask = 86
                CurrentTick = 0
                TimerTasks.Stop()
            End If
            SendKeys.Send(CurrentURL)
            SendKeys.Send("{TAB}")
            SendKeys.Send("250")
            SendKeys.Send("{ENTER}")
            Thread.Sleep(2000)
            ChangeStatus("Searching for continue button (" & SearchErrors & " of 15)")
            CurrentTask = 86
            CurrentTick = 0
            CurrentVideo += 1
        ElseIf CurrentTask = 86 Then
            'Searching for continue button
            ChangeStatus("Searching for url textbox (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("u2bviews14")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 87
                    SearchErrors = 0
                    ChangeStatus("Clicking continue button")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                ShowError("Couldn't find the image 'u2bviews14'")
            End If
        ElseIf CurrentTask = 87 Then
            'Clicking continue button {loop with 83}
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
                SearchErrors = 0
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Entering info")
                CurrentTask = 83
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 88 Then
            'Ending
            TimerTasks.Stop()
            CurrentTask = 0
            CurrentTick = 0
            SearchErrors = 0
            My.Settings.CurrentAccount = 1
            My.Settings.CurrentVideo = 1
            My.Settings.CurrentURL = String.Empty
            CurrentAccount = 1
            CurrentAfterLastName = String.Empty
            CurrentDescription = String.Empty
            CurrentEmail = String.Empty
            CurrentFirstName = String.Empty
            CurrentLastName = String.Empty
            CurrentPassword = String.Empty
            CurrentRandomNumber = 0
            CurrentU2bviewsAccount = String.Empty
            CurrentU2bviewsPassword = String.Empty
            CurrentURL = String.Empty
            CurrentVideo = String.Empty
            BtnStart.Text = "Start"
            Me.Location = LastLocation
            ProgressBarProgress.Value = 0
            ChangeStatus("Finished in " & TotalTimeProcess)
            LabelStatus.ForeColor = Color.Green
        ElseIf CurrentTask = 89 Then
            'PAUSE XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
            'Clearing cookies
            SendKeys.Send("^+{DELETE}")
            CurrentTick += 1
            If CurrentTick = 50 Then
                SendKeys.Send("{ENTER}")
            ElseIf CurrentTick = 55 Then
                CurrentTask = 90
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 90 Then
            'Opening router page 192.168.2.1
            CurrentTick += 1
            If CurrentTick = 5 Then
                Process.Start(My.Settings.FirefoxPath, "192.168.2.1")
            ElseIf CurrentTick >= 60 Then
                ChangeStatus("Searching for restart button (" & SearchErrors & " of 25)")
                CurrentTask = 91
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 91 Then
            'Searching for restart button
            ChangeStatus("Searching for restart button (" & SearchErrors & " of 25)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("iprestart")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 92
                    SearchErrors = 0
                    ChangeStatus("Clicking restart button")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 25 Then
                ShowError("Couldn't find the image 'iprestart'")
            End If
        ElseIf CurrentTask = 92 Then
            'Clicking restart button
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
                SearchErrors = 0
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Searching for submit button (" & SearchErrors & " of 25)")
                CurrentTask = 93
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 93 Then
            'Searching for submit button
            ChangeStatus("Searching for submit button (" & SearchErrors & " of 25)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("ipsubmit")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 94
                    SearchErrors = 0
                    ChangeStatus("Clicking submit button")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 25 Then
                ShowError("Couldn't find the image 'ipsubmit'")
            End If
        ElseIf CurrentTask = 94 Then
            'Clicking submit button
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
                SearchErrors = 0
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Searching for restart button (" & SearchErrors & " of 25)")
                CurrentTask = 95
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 95 Then
            'Searching for restart button
            ChangeStatus("Searching for restart button (" & SearchErrors & " of 25)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("iprestart2")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 96
                    SearchErrors = 0
                    ChangeStatus("Clicking restart button")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 25 Then
                ShowError("Couldn't find the image 'iprestart2'")
            End If
        ElseIf CurrentTask = 96 Then
            'Clicking restart button
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
                SearchErrors = 0
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Sending 2 enter")
                CurrentTask = 97
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 97 Then
            'Sending 2 enters
            CurrentTick += 1
            If CurrentTick = 5 Then
                SendKeys.Send("{ENTER}")
            ElseIf CurrentTick = 15 Then
                SendKeys.Send("{ENTER}")
            ElseIf CurrentTick = 20 Then
                ChangeStatus("Checking for internet")
                CurrentTask = 98
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 98 Then
            'Checking internet connection
            CurrentTick += 1
            If CurrentTick >= 25 Then
                Try
                    Using client As New WebClient()
                        Using Stream = client.OpenRead("http://www.bing.com/")
                            ChangeStatus("Closing Firefox")
                            CurrentTask = 99
                            CurrentTick = 0
                        End Using
                    End Using
                Catch ex As Exception
                    CurrentTick = 0
                End Try
            End If
        ElseIf CurrentTask = 99 Then
            'Closing Firefox
            CurrentTick += 1
            If CurrentTick = 5 Then
                SendKeys.Send("%{F4}")
            ElseIf CurrentTick = 55 Then
                ChangeStatus("Going to the next account")
                CurrentTask = 1
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 102 Then
            'Checking for hotmail capcha error
            ChangeStatus("Searching for capcha error (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("hotmail03-2")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    SearchErrors = 0
                    CurrentTask = 103
                    ChangeStatus("Invalid capcha found")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                SearchErrors = 0
                CurrentTask = 12
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 103 Then
            'Restarting to capcha
            CurrentTick += 1
            If CurrentTick = 5 Then
                SendKeys.Send("{UP 10}")
            ElseIf CurrentTick = 10 Then
                CurrentTick = 0
                CurrentTask = 104
                ChangeStatus("Searching for password label (" & SearchErrors & " of 15)")
            End If
        ElseIf CurrentTask = 104 Then
            'Searching for password label
            ChangeStatus("Searching for password label (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("hotmailcapcha")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 105
                    SearchErrors = 0
                    ChangeStatus("Clicking password label")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 25 Then
                ShowError("Couldn't find the image 'hotmailcapcha'")
            End If
        ElseIf CurrentTask = 105 Then
            'Clicking password label
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Entering info")
                CurrentTask = 106
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 106 Then
            'Going to capcha
            CurrentTick += 1
            If CurrentTick = 5 Then
                SendKeys.Send(CurrentPassword)
                SendKeys.Send("{TAB}")
                SendKeys.Send(CurrentPassword)
                SendKeys.Send("{TAB 12}")
            ElseIf CurrentTick = 10 Then
                ChangeStatus("Waiting for capcha, press F9 when done")
                TimeForCapcha = True
                DoneWithCapcha = False
                CurrentTask = 10
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 107 Then
            'Pressing alt-f4
            CurrentTick += 1
            If CurrentTick = 5 Then
                SendKeys.Send("%{F4}")
            ElseIf CurrentTick > 50 Then
                CurrentTask = 90
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 108 Then
            'Checking for youtube invalid capcha
            ChangeStatus("Searching for capcha error (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("youtube04-2")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    SearchErrors = 0
                    CurrentTask = 109
                    ChangeStatus("Invalid capcha found")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 15 Then
                SearchErrors = 0
                CurrentTask = 12
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 109 Then
            'Restarting to capcha
            CurrentTick += 1
            If CurrentTick = 5 Then
                SendKeys.Send("{UP 10}")
            ElseIf CurrentTick = 10 Then
                CurrentTick = 0
                CurrentTask = 110
                ChangeStatus("Searching for password label (" & SearchErrors & " of 15)")
            End If
        ElseIf CurrentTask = 110 Then
            'Searching for password label
            ChangeStatus("Searching for password label (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 5 Then
                LocationFound = ImageSearch("ytpasswordlabel")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 111
                    SearchErrors = 0
                    ChangeStatus("Clicking password label")
                End If
            ElseIf CurrentTick > 5 Then
                CurrentTick = 0
            End If
            If SearchErrors = 25 Then
                ShowError("Couldn't find the image 'ytpasswordlabel'")
            End If
        ElseIf CurrentTask = 111 Then
            'Clicking password label
            CurrentTick += 1
            If CurrentTick = 5 Then
                SetCursorPos(LocationFound.X, LocationFound.Y)
                ClickMouse("left")
                LocationFound = New Point(0, 0)
            ElseIf CurrentTick > 5 Then
                ChangeStatus("Entering info")
                CurrentTask = 112
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 112 Then
            'Going to capcha
            CurrentTick += 1
            If CurrentTick = 5 Then
                SendKeys.Send(CurrentPassword)
                SendKeys.Send("{TAB}")
                SendKeys.Send(CurrentPassword)
                SendKeys.Send("{TAB 8}")
            ElseIf CurrentTick = 10 Then
                ChangeStatus("Waiting for capcha, press F9 when done")
                DontCheck = True
                TimeForCapcha = True
                DoneWithCapcha = False
                CurrentTask = 19
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 113 Then
            'Check for phone verification
            ChangeStatus("Searching verify account (" & SearchErrors & " of 15)")
            CurrentTick += 1
            If CurrentTick = 25 Then
                LocationFound = ImageSearch("ytphone")
                If LocationFound = New Point(0, 0) Then
                    SearchErrors += 1
                Else
                    CurrentTick = 0
                    CurrentTask = 114
                    SearchErrors = 0
                    ChangeStatus("Restarting process")
                End If
            ElseIf CurrentTick > 25 Then
                CurrentTick = 20
            End If
            If SearchErrors >= 15 Then
                CurrentTask = 22
                CurrentTick = 0
            End If
        ElseIf CurrentTask = 114 Then

        End If
    End Sub

    Private Sub TimerTotalTime_Tick(sender As Object, e As EventArgs) Handles TimerTotalTime.Tick
        TotalTime = TotalTime + 1
        TotalTimeProcess = Format(Int(TotalTime / 3600), "0#") & "h " & Format(Int(TotalTime / 60) Mod 60, "0#") & "m " & Format(TotalTime Mod 60, "0#") & "s"
    End Sub

    Private Sub TimerAlarm_Tick(sender As Object, e As EventArgs) Handles TimerAlarm.Tick
        If TimeForCapcha = True And AlarmStarted = False Then
            My.Computer.Audio.Play(My.Resources.alarm, AudioPlayMode.Background)
            AlarmStarted = True
        ElseIf TimeForCapcha = False Then
            AlarmStarted = False
        End If
    End Sub

    Private Sub TimerTheTime_Tick(sender As Object, e As EventArgs) Handles TimerTheTime.Tick
        UpSeconds = UpSeconds + 1
        LabelUpTime.Text = "Up Time: " & Format(Int(UpSeconds / 3600), "0#") & "h " & Format(Int(UpSeconds / 60) Mod 60, "0#") & "m " & Format(UpSeconds Mod 60, "0#") & "s"
        LabelTime.Text = "Time: " & Format(Int(DateAndTime.Now.Hour), "0#") & "h " & Format(Int(DateAndTime.Now.Minute), "0#") & "m " & Format(Int(DateAndTime.Now.Second), "0#") & "s"
    End Sub
End Class